package org.come.Frame;

import java.awt.Component;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;

import javax.swing.BorderFactory;
import javax.swing.JInternalFrame;
import javax.swing.plaf.basic.BasicInternalFrameUI;

import org.come.Jpanel.HallucinationJpanel;
import org.come.until.FormsManagement;
import org.come.until.Music;
import org.come.until.ScrenceUntil;

import com.tool.tcpimg.UIUtils;

public class HallucinationJframe extends JInternalFrame implements MouseListener {
	private HallucinationJpanel HallucinationJpanel;
	private int first_x;
	private int first_y;

	public static HallucinationJframe getHallucinationJframe() {
		return (HallucinationJframe) FormsManagement.getInternalForm(3019).getFrame();
	}

	public HallucinationJframe() {
		this.HallucinationJpanel = new HallucinationJpanel();
		add((Component) this.HallucinationJpanel);

		setBorder(BorderFactory.createEmptyBorder());
		((BasicInternalFrameUI) getUI()).setNorthPane(null);

		setBounds(ScrenceUntil.Screen_x/2-616/2, ScrenceUntil.Screen_y/2-442/2, 616, 442);
		setOpaque(false);
		pack();
		setBackground(UIUtils.Color_BACK);
		setVisible(false);
		setDefaultCloseOperation(3);

		addMouseListener(this);
		addMouseMotionListener(new MouseMotionListener() {
			public void mouseMoved(MouseEvent e) {
			}

			public void mouseDragged(MouseEvent e) {
				if (HallucinationJframe.this.isVisible()) {
					int x = e.getX() - HallucinationJframe.this.first_x;
					int y = e.getY() - HallucinationJframe.this.first_y;
					HallucinationJframe.this.setBounds(x + HallucinationJframe.this.getX(),
							y + HallucinationJframe.this.getY(), HallucinationJframe.this.getWidth(),
							HallucinationJframe.this.getHeight());
				}
			}
		});
	}

	public void mouseClicked(MouseEvent e) {
	}

	public void mousePressed(MouseEvent e) {
		Music.addyinxiao("关闭窗口.mp3");

		if (e.isMetaDown()) {
			FormsManagement.HideForm(3019);
		} else {
			FormsManagement.Switchinglevel(3019);
		}
		this.first_x = e.getX();
		this.first_y = e.getY();
	}

	public void mouseReleased(MouseEvent e) {
	}

	public void mouseEntered(MouseEvent e) {
	}

	public void mouseExited(MouseEvent e) {
	}

	public HallucinationJpanel getHallucinationJpanel() {
		return this.HallucinationJpanel;
	}

	public void setHallucinationJpanel(HallucinationJpanel HallucinationJpanel) {
		this.HallucinationJpanel = HallucinationJpanel;
	}
}
